import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    component: () => import('../views/Home/index.vue')
  },
  {
    path: '/classfiy',
    component: () => import('../views/classfiy/index.vue')
  },
  {
    path: '/vip',
    component: () => import('../views/Vip/index.vue')
  },
  {
    path: '/shopcer',
    component: () => import('../views/shopcer/index.vue')
  },
  {
    path: '/my',
    component: () => import('../views/My/index.vue')
  },
  {
    path: '/login',
    component: () => import('../views/login.vue')
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

let whiteList = ["/", "/classfiy", "/login"]
router.beforeEach((to, from, next) => {
  let is = whiteList.includes(to.path)
  if (is) {
    next()
  } else {
    next("/login")
  }
})


export default router